//
//  FlowTilteView.swift
//  Employee
//
//  Created by swordjoy on 2017/6/26.
//  Copyright © 2017年 remotevillage. All rights reserved.
//

import UIKit

class FlowTilteView: UIView {

  static let identifier = "FlowTilteView.identifier"
  
  fileprivate var containerView: UIView!
  fileprivate var titleLabel: UILabel!
  fileprivate var moreButton: UIButton!
  
  override init(frame: CGRect) {
    super.init(frame: frame)
    backgroundColor = UIColor.white
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

}

// MARK: - action

extension FlowTilteView {
  
  @objc fileprivate func moreAction() {
    moreButton.isSelected = !moreButton.isSelected
  }
  
}

// MARK: - fileprivate

extension FlowTilteView {
  fileprivate func create() {
    containerView = UIView()
    addSubview(containerView)
    containerView.backgroundColor = UIColor.white
    containerView.snp.makeConstraints { (make) in
      make.left.top.equalTo(10)
      make.right.equalTo(-10)
      make.bottom.equalToSuperview()
    }
    containerView.layer.cornerRadius = 2
    containerView.clipsToBounds = true
    
    titleLabel = UILabel.getLabel(with: GlobalConfig.system16Font, textColor: GlobalConfig.TextDeepColor, textAlignment: .left)
    containerView.addSubview(titleLabel)
    titleLabel.snp.makeConstraints { (make) in
      make.left.equalTo(15)
      make.centerY.equalToSuperview()
      make.right.equalTo(100)
    }
    
    moreButton = UIButton()
    containerView.addSubview(moreButton)
    let offImage = UIImage(named: "func_more_off")
    let onImage = UIImage(named: "func_more_on")
    moreButton.setImage(offImage, for: .normal)
    moreButton.setImage(onImage, for: .selected)
    moreButton.isSelected = false
    moreButton.addTarget(self, action: #selector(moreAction), for: .touchUpInside)
    moreButton.snp.makeConstraints { (make) in
      make.centerY.equalToSuperview()
      make.right.equalTo(15)
      make.height.width.equalTo(44)
    }
  }
  
}
